﻿//***********************************************************************
// Assembly         : IGolovkine.AoA.Core
// Author           : Ilia
// Created          : 06-11-2011
//
// Last Modified By : Ilia
// Last Modified On : 06-11-2011
// Description      : 
//
// Copyright        : (c) Microsoft. All rights reserved.
//***********************************************************************
using System.Collections.Generic;
using System.Reactive.Linq;

namespace IGolovkine.AoA.Tcp
{
    public class TcpTunnelConfiguration : IConfiguration<TcpTunnel>
    {
        private List<TcpTunnelRoute> _routes;
        private IConfiguration<IMessageChannel> _channel;

        public TcpTunnelConfiguration()
        {
            _routes = new List<TcpTunnelRoute>();
        }

        public IConfiguration<IMessageChannel> Channel
        {
            get { return _channel; }
            set { _channel = value; }
        }

        public List<TcpTunnelRoute> Routes
        {
            get { return _routes; }
            set { _routes = value; }
        }

        public TcpTunnel CreateInstance()
        {
            var result = new TcpTunnel(_channel.CreateInstance());
            _routes.ToObservable().Subscribe(result.Routes);
            return result;
        }
    }
}
